import 'dart:async';
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:riki_push/enum/phone_platform.dart';
import 'package:riki_push/factory/riki_base_push.dart';
import 'package:riki_base_flutter/riki_base_flutter.dart';
import 'package:riki_push/listener/mz_push_plugin_listener.dart';

///
///  vivo推送
///
class RikiMeizuPush {
  static const MethodChannel _channel_meizu = const MethodChannel('riki_push_meizu');

  /// 初始化 魅族
  static Future<void> init({@required String appId, @required String appKey}) async {
    return await _channel_meizu.invokeMethod('initMeizu', {
      "appId": appId,
      "appKey": appKey,
    });
  }

  /// 获取meizuRid
  static Future<String> get meizuRid async {
    String meizuRegId = '';
    if (Platform.isAndroid && await RikiBasePush.phonePlatform == PhonePlatform.meizu) {
      meizuRegId = await _channel_meizu.invokeMethod('getMeizuRegId');
    }
    LogUtil.v("meizuRegId是" + meizuRegId);
    return meizuRegId;
  }

  /// 反初始化
  static Future<void> unInit({@required String appId, @required String appKey}) async {
    return await _channel_meizu.invokeMethod('unInit', {
      "appId": appId,
      "appKey": appKey,
    });
  }
}
